package com.chanyachting.emall.domain;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.chanyachting.emall.dao.ProductcategoryDAO;
import com.chanyachting.emall.domain.base.BaseProductcategory;

/**
 * This is the object class that relates to the productcategory table.
 * Any customizations belong here.
 */
public class Productcategory extends BaseProductcategory {

/*[CONSTRUCTOR MARKER BEGIN]*/
	public Productcategory () {
		super();
	}

	/**
	 * Constructor for primary key
	 */
	public Productcategory (java.lang.Integer _id) {
		super(_id);
		
		Productcategory pc=(Productcategory)new ProductcategoryDAO().load(Productcategory.class, _id);
		
		if(pc!=null){
			
			try {
				BeanUtils.copyProperties(this, pc);
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/**
	 * Constructor for required fields
	 */
	public Productcategory (
		java.lang.Integer _id,
		java.lang.Integer _businesscategoryId) {

		super (
			_id,
			_businesscategoryId);
	}

/*[CONSTRUCTOR MARKER END]*/
	
	
	public static List<Productcategory> list(){
		
		return new ProductcategoryDAO().find("from Productcategory");
		
	}
	
	
	public static List<Productcategory> listByBusinessCategoryId(int bcategoryId){
		
		String args[]={String.valueOf(bcategoryId)};
		
		return new ProductcategoryDAO().find("from Productcategory where businesscategoryId=?",args);
	}
	
	
}



